package cn.source.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.BuzMember;
import cn.source.system.service.IBuzMemberService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 会员信息Controller
 * 
 * @author sourcebyte.vip
 * @date 2024-05-01
 */
@RestController
@RequestMapping("/system/buzMember")
public class BuzMemberController extends BaseController
{
    @Autowired
    private IBuzMemberService buzMemberService;

    /**
     * 查询会员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzMember buzMember)
    {
        startPage();
        List<BuzMember> list = buzMemberService.selectBuzMemberList(buzMember);
        return getDataTable(list);
    }

    /**
     * 导出会员信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:export')")
    @Log(title = "会员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzMember buzMember)
    {
        List<BuzMember> list = buzMemberService.selectBuzMemberList(buzMember);
        ExcelUtil<BuzMember> util = new ExcelUtil<BuzMember>(BuzMember.class);
        util.exportExcel(response, list, "会员信息数据");
    }

    /**
     * 获取会员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(buzMemberService.selectBuzMemberById(id));
    }

    /**
     * 新增会员信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:add')")
    @Log(title = "会员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzMember buzMember)
    {
        return toAjax(buzMemberService.insertBuzMember(buzMember));
    }

    /**
     * 修改会员信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:edit')")
    @Log(title = "会员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzMember buzMember)
    {
        return toAjax(buzMemberService.updateBuzMember(buzMember));
    }

    /**
     * 删除会员信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzMember:remove')")
    @Log(title = "会员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzMemberService.deleteBuzMemberByIds(ids));
    }
}
